basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
testdir=./testfiles
filedir=(./1MB ./2MB ./4MB ./8MB ./16MB ./32MB ./64MB ./128MB ./256MB)
filesize=(1 2 4 8 16 32 64 128 256)

round=8

for ((i=0; i<$round; i++))
do	
	cd $basedir
	echo "in $basedir"
	echo "modifying the size of the file to be generated"
	sed "/FILE_SIZE 0/s//FILE_SIZE ${filesize[i]}/g" fileread_base.c > fileread.c
	mv fileread.c fileread_v.c
	sed "/0MB/s//${filesize[i]}MB/g" fileread_v.c > fileread.c
	make
	sudo sh -c 'sync && echo 1 > /proc/sys/vm/drop_caches'
	./fileread > ./result_read_${filesize[i]}MB.txt
	echo "round i: file size = ${filesize[i]}"
	cat ./result_read_${filesize[i]}MB.txt
	rm fileread.c fileread_v.c
	make clean
done
